package com.xbts.system.domain;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xbts.common.core.annotation.Excel;
import com.xbts.common.core.web.domain.BaseIdEntity ;
import com.xbts.common.core.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import javax.validation.constraints.NotEmpty;

/**
 * 第三方公司用户账号信息绑定对象 sys_thrid_bind
 * 
 * @author xbts
 * @date 2023-12-22
 */
@Data
@ApiModel(value = "SysThridBind", description = "第三方公司用户账号信息绑定对象")
@TableName("sys_third_bind")
public class SysThirdBind extends BaseIdEntity {
    private static final long serialVersionUID = 1L;

    /** 本系统用户id */
    @Excel(name = "本系统用户id")
    @ApiModelProperty("本系统用户id")
    private Long userId;

    /** sys_third_sys_path 表id */
    @Excel(name = "sys_third_sys_path 表id")
    @ApiModelProperty("第三方系统表id")
    @NotEmpty(message = "请选择第三方系统",groups = {Insert.class, Update.class})
    private Long thirdSystemId;

    /**
     * 系统名称
     */
    @Excel(name = "系统名称")
    @ApiModelProperty("系统名称")
    private String systemName;

    /** 第三方系统用户名 */
    @Excel(name = "第三方系统用户名")
    @ApiModelProperty("第三方系统用户名")
    @NotEmpty(message = "第三方系统用户名不能为空",groups = {Insert.class, Update.class})
    private String username;

    /** 第三方系统密码 */
    @Excel(name = "第三方系统密码")
    @ApiModelProperty("第三方系统密码")
    private String password;

    public <T> QueryWrapper<T> queryWrapper() {
        QueryWrapper<T> wrapper=new QueryWrapper<>();

        wrapper.eq(userId != null,"user_id" , userId);
        wrapper.eq(thirdSystemId != null,"third_system_id" , thirdSystemId);
        wrapper.like(StringUtils.isNotEmpty(username),"username" , username);
        wrapper.like(StringUtils.isNotEmpty(password),"password" , password);
        wrapper.orderByDesc("create_time");
        return wrapper;
    }

}
